<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>社区公告</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(-45deg, #e9e2f3, #d4c9e8, #d1c9ec);
            background-size: 400% 400%;
            animation: gradient 8s ease infinite;
            min-height: 100vh;
            padding: 2rem 0;
            margin: 0;
        }
        @keyframes gradient {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        .card {
            background-color: rgba(255, 255, 255, 0.9);
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            backdrop-filter: blur(5px);
            padding: 2rem;
            max-width: 900px;
            margin: 0 auto;
        }
        .card-title {
            color: #333;
            font-weight: 700;
            margin-bottom: 1.5rem;
            position: relative;
            padding-bottom: 0.5rem;
            text-align: center;
        }
        .card-title::after {
            content: '';
            width: 50px;
            height: 3px;
            background-color: #8ab4f8;
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
        }
        .announcement-item {
            border-bottom: 1px solid #eee;
            padding: 1.2rem 0;
            transition: background-color 0.3s ease;
        }
        .announcement-item:hover {
            background-color: rgba(138, 180, 248, 0.05);
        }
        .announcement-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }
        .announcement-title {
            font-weight: 600;
            color: #2d3748;
            text-decoration: none;
            display: flex;
            align-items: center;
        }
        .announcement-title:hover {
            color: #6ea8f5;
            text-decoration: underline;
        }
        .top-tag {
            background-color: #f87171;
            color: white;
            font-size: 0.8rem;
            padding: 0.1rem 0.5rem;
            border-radius: 4px;
            margin-right: 0.5rem;
        }
        .announcement-meta {
            color: #999;
            font-size: 0.9rem;
        }
        .announcement-content {
            color: #666;
            margin-bottom: 0.5rem;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .no-announcement {
            text-align: center;
            color: #999;
            padding: 3rem 0;
        }
    </style>
</head>
<body>
<div class="card">
    <h3 class="card-title">社区公告</h3>

    <!-- 公告列表 -->
    <div th:each="ann : ${announcements}">
        <div class="announcement-item">
            <div class="announcement-header">
                <a th:href="@{/content/announcement/detail/{id}(id=${ann.id})}" class="announcement-title">
                    <span th:if="${ann.isTop}" class="top-tag">置顶</span>
                    <span th:text="${ann.title}"></span>
                </a>
                <span class="announcement-meta" th:text="${#dates.format(ann.publishTime, 'yyyy-MM-dd')}"></span>
            </div>
            <div class="announcement-content" th:text="${ann.content}"></div>
            <div class="announcement-meta">发布人：<span th:text="${ann.publisher}"></span></div>
        </div>
    </div>

    <!-- 无公告时显示 -->
    <div th:if="${announcements.isEmpty()}" class="no-announcement">
        <i class="bi bi-bullhorn" style="font-size: 3rem; color: #eee; margin-bottom: 1rem;"></i>
        <p>暂无社区公告，敬请期待～</p>
    </div>
</div>

<!-- 引入图标库 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>